package ch.ethz.fcl.metrobuzz.algorithm.voronoi.interpolation;

import org.lwjgl.opengl.GL11;
import org.lwjgl.util.glu.Cylinder;

import ch.ethz.fcl.metrobuzz.MBContainer;
import ch.ethz.fcl.metrobuzz.algorithm.network.shortest_path.public_transport.Walk;
import ch.ethz.fcl.metrobuzz.spatialindex.object2d.Point2D;
import ch.ethz.fcl.metrobuzz.tools.MBGL;

public class InterpolationVoronoiCell {
	protected float weight;
	protected Point2D center;

	private Cylinder cone;

	public InterpolationVoronoiCell(float x, float y, float weight) {
		this(new Point2D(x, y), weight);
	}

	public InterpolationVoronoiCell(Point2D center, float weight) {
		this.center = center;
		this.weight = weight;
		cone = new Cylinder();
	}

	public void render(MBContainer container, float timeLimit) {
		GL11.glPushMatrix();
		float walkDist = Walk.getWalkScreenLength(container.getData(), weight);

		float depth = 1;
		GL11.glTranslatef(center.getX(), center.getY(), -depth);

		float weightedDepth = weight / timeLimit;

		cone.draw(walkDist, 0, weightedDepth, 100, 30);

		GL11.glColor4f(0, 0, 0, 1);
		GL11.glLineWidth(2.0f);
		MBGL.renderEclipse(0, 0, 0, walkDist, walkDist, false);

		GL11.glPopMatrix();
	}

	public float getWeight() {
		return weight;
	}
}
